<?php
 /******************************************************************************
 *   GunCMS is an avid supporter of open source software. This is the appropriate 
 *   option if you are creating an open source application with a license 
 *   compatible with the GNU GPL license v3.
 *   For details http://www.gnu.org/licenses/gpl.html
 *   DO NOT USE FOR COMMERCIAL WITHOUT PERMISSION
 *
 * GunCMS Version 1.0.3
 * Copyright(c) 2009-2010, T & L GdbR
 * info@guncms.de
 * 
 * http://www.guncms.de
 ********************************************************************************/
class FgcmsCategoryBean {
	
	public function __construct() {
	// contructor function
	}
	
	/*returns the whole active left sided category table, with the
	 * parent $cat and the given language $lang
	 */ 
	public static function get_cat_by_condition($db,$cat,$lang,$position,$widget) {
		if($position!="")
			$strpo = "$position ='1' AND "	;
    	$strSQL = sprintf("SELECT * FROM ".TBL_CATEGORY.
    			" WHERE $strpo cat_is_active = '1' AND cat_parent='$cat' AND widget_id='$widget' AND lang_id ='$lang' ORDER BY cat_position ");
    	return $db->get_results($strSQL);
    }
	
	/*returns the name of menu top, with the  cat_id $id */ 
	public static function get_catname_by_id($db,$id) {
    	$strSQL = sprintf("SELECT cat_name FROM ".TBL_CATEGORY.
    			" WHERE cat_id 	='$id' ");
    	return $db->get_row($strSQL);
    }
	
	public static function get_banner_by_id($db,$id) {
    	$strSQL = sprintf("SELECT banner_path FROM ".TBL_CATEGORY.
    			" WHERE cat_id 	='$id' ");
    	return $db->get_row($strSQL);
    }
	
	public static function get_default_category($db) {
		$strSQL = sprintf("SELECT cat_id,cat_name,cat_parent FROM ".TBL_CATEGORY." WHERE cat_default = '1'");
    	$res = $db->get_row($strSQL);		
		return $res;
    }
}
?>
